<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Usman extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	function __construct()
	{
		parent::__construct();
		$this->load->model('ktig');
	}
	public function index()
	{
		$this->load->helper('url');
		$this->load->view('header');
		
		$this->ktig->is_logged_in();
		if($this->session->userdata('role')!=5) { redirect('land'); }
		
		$this->load->view('v_usman');
	}
	public function input_form()
	{
		$this->load->helper('url');
		$data=array(
			'NAMA'=>$this->input->post('nama'),
			'USERNAME'=>$this->input->post('username'),
			'PASSWORD'=>$this->input->post('password'),
			'ROLE'=>$this->input->post('role'),
			'BAGIAN'=>$this->input->post('bagian'),
			'Departemen'=>$this->input->post('departemen'),
			'NIK'=>$this->input->post('nik'),
			'Jabatan'=>$this->input->post('jabatan')
		  );
		$this->db->insert('user',$data);
		
		redirect('usman/lihat');
	}
	
	
	public function lihat()
	{
		$this->load->helper('url');
		$this->load->view('header');
		
		$data['datalist'] = $this->ktig->list_usman();
		
		$this->ktig->is_logged_in();
		if($this->session->userdata('role')!=5) { redirect('land'); }
		
		$this->load->view('v_usman_lihat',$data);
	}
	public function hapus($id)
	{
		$this->load->helper('url');
		$this->ktig->hapus_usman($id);
		redirect('usman/lihat');
	}
	public function ubah($id)
	{
		$this->load->helper('url');
		$this->load->view('header');
		if($this->input->post('submit'))
		{
			$this->ktig->update_usman($id);
			redirect('usman/lihat');
		}
		
		$this->ktig->is_logged_in();
		if($this->session->userdata('role')!=5) { redirect('land'); }
		
		$data['hasil']=$this->ktig->data_usman($id);
		$this->load->view('v_usman_ubah',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */